package suites.as3Core.utilites.bitwise.cases
{
	import com.powwow.as3Core.utilites.bitwise.setBitsOff;

	import org.flexunit.asserts.assertEquals;

	public class BitwiseSetBitsOffTest
	{

		[Before]
		public function setUp():void
		{
		}

		[After]
		public function tearDown():void
		{
		}

		[BeforeClass]
		public static function setUpBeforeClass():void
		{
		}

		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}


		[Test]
		public function test_zero_zero():void
		{
			//given 
			const value:uint=0;
			const bits:uint=0;
			//when 
			const result:uint=setBitsOff(value, bits);
			//then
			assertEquals(0, result);
		}

		[Test]
		public function test_zero_nonzero():void
		{
			//given 
			const value:uint=0;
			const bits:uint=2 + 4;
			//when 
			const result:uint=setBitsOff(value, bits);
			//then
			assertEquals(0, result);
		}

		[Test]
		public function test_nonzero_zero():void
		{
			//given 
			const value:uint=6;
			const bits:uint=0;
			//when 
			const result:uint=setBitsOff(value, bits);
			//then
			assertEquals(0, result);
		}

		[Test]
		public function test_turn_off_all1():void
		{
			//given 
			const value:uint=200;
			const bits:uint=0xFFFFFFFF;
			//when 
			const result:uint=setBitsOff(value, bits);
			//then
			assertEquals(0, result);
		}

		[Test]
		public function test_turn_off_all2():void
		{
			//given 
			const value:uint=0xFFFFFFFF;
			const bits:uint=0xFFFFFFFF;
			//when 
			const result:uint=setBitsOff(value, bits);
			//then
			assertEquals(0, result);
		}

		[Test]
		public function test_turn_off_with_maxInt1():void
		{
			//given 
			const value:uint=0xFFFFFFFF;
			const bits:uint=1;
			//when 
			const result:uint=setBitsOff(value, bits);
			//then
			assertEquals(0xFFFFFFFE, result);
		}

		[Test]
		public function test_turn_off_with_maxInt2():void
		{
			//given 
			const value:uint=0xFFFFFFFF;
			const bits:uint=0x80000000;
			//when 
			const result:uint=setBitsOff(value, bits);
			//then
			assertEquals(0x7FFFFFFF, result);
		}

		[Test]
		public function test_turn_off_with_maxInt3():void
		{
			//given 
			const value:uint=0xFFFFFFFF;
			const bits:uint=0x7FFFFFFF;
			//when 
			const result:uint=setBitsOff(value, bits);
			//then
			assertEquals(0x80000000, result);
		}

		[Test]
		public function test_turn_off_matched():void
		{
			//given 
			const value:uint=parseInt("100000110", 2);
			const _bits:uint=parseInt("100000110", 2);
			//when 
			const result:uint=setBitsOff(value, _bits);
			//then
			assertEquals(0, result);
		}

		[Test]
		public function test_turn_off_intersected1():void
		{
			//given 
			const value:uint=parseInt("100000110", 2);
			const _bits:uint=parseInt("000000110", 2);
			const _res_:uint=parseInt("100000000", 2);
			//when 
			const result:uint=setBitsOff(value, _bits);
			//then
			assertEquals(_res_, result);
		}

		[Test]
		public function test_turn_off_intersected2():void
		{
			//given 
			const value:uint=parseInt("100000110", 2);
			const _bits:uint=parseInt("000100110", 2);
			const _res_:uint=parseInt("100000000", 2);
			//when 
			const result:uint=setBitsOff(value, _bits);
			//then
			assertEquals(_res_, result);
		}

		[Test]
		public function test_turn_off_intersected3():void
		{
			//given 
			const value:uint=parseInt("100000110", 2);
			const _bits:uint=parseInt("000100100", 2);
			const _res_:uint=parseInt("100000010", 2);
			//when 
			const result:uint=setBitsOff(value, _bits);
			//then
			assertEquals(_res_, result);
		}

		[Test]
		public function test_turn_off_nonintersected():void
		{
			//given 
			const value:uint=parseInt("100000110", 2);
			const _bits:uint=parseInt("000100001", 2);
			const _res_:uint=parseInt("100000110", 2);
			//when 
			const result:uint=setBitsOff(value, _bits);
			//then
			assertEquals(_res_, result);
		}
	}
}
